package com.zzzzzz.oms.constractor;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.validation.ConstraintViolationException;
import javax.validation.Validator;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zzzzzz.core.datagrid.BaseData;
import com.zzzzzz.plugins.shiro.I;
import com.zzzzzz.utils.BeanValidators;
import com.zzzzzz.utils.DateTimeUtils;

@Service
public class ConstractorService {
	@Resource
	public ConstractorDao constractorDao;
	
	@Resource
	public Validator validator;
	
	// 增加、修改
	@Transactional
	public int save(Constractor constractor, I i) {
		constractor.setUpdDt(new Date());
		constractor.setUpdBy(i.getId());
		if (constractor.getId() == null) {
			constractor.setAddDt(new Date());
			constractor.setAddBy(i.getId());
			constractor.setPlatformId(i.getPlatformId());
			constractorDao.add(constractor);
		} else {
			constractorDao.updById(constractor);
		}
		return 1;
	}
	
	private static final Logger logger = LoggerFactory.getLogger(Constractor.class);
}
